<template>
	<view class="container">
		<!-- 顶部安全区域占位 -->
		<!-- 	<view class="status-bar"></view> -->

		<!-- 顶部导航栏 -->
		<!-- <uni-nav-bar left-icon="left" title="维修任务" backgroundColor="#2a8cff" color="#fff" @clickLeft="goBack" /> -->

		<!-- 搜索栏 -->
		<view class="search-container">
			<view class="search-box">
				<uni-icons type="search" size="28" color="#999" class="search-icon"></uni-icons>
				<input type="text" placeholder="搜索维修单号、车主姓名..." class="search-input" v-model="searchText" />
			</view>
		</view>

		<!-- 筛选条件 -->
		<view class="filter-bar">
			<view class="stats-info">
				<text class="total-count">共 {{ tasks.length }} 条任务</text>
			</view>
			<view class="filter-options">
				<view class="filter-item">
					<uni-picker mode="selector" :range="statusOptions" @change="onStatusChange" class="filter-picker">
						<view class="filter-value">
							<text>{{ selectedStatus }}</text>
							<uni-icons type="arrowdown" size="14" color="#fff"></uni-icons>
						</view>
					</uni-picker>
				</view>
				<view class="filter-item">
					<uni-picker mode="selector" :range="repairTypeOptions" @change="onRepairTypeChange"
						class="filter-picker">
						<view class="filter-value">
							<text>{{ selectedRepairType }}</text>
							<uni-icons type="arrowdown" size="14" color="#fff"></uni-icons>
						</view>
					</uni-picker>
				</view>
				<view class="filter-item date-filter">
					<uni-icons type="calendar" size="20" color="#fff"></uni-icons>
					<text class="date-text">日期</text>
				</view>
			</view>
		</view>

		<!-- 任务列表 -->
		<view class="task-list">
			<view class="task-item" v-for="(task, index) in tasks" :key="index" @click="viewDetail(task.id)">
				<!-- 任务状态标签 -->
				<view class="task-status-badge" :class="getStatusClass(task.status)">
					{{ task.status }}
				</view>

				<view class="task-header">
					<view class="task-number-section">
						<text class="task-id">维修单号: {{ task.id }}</text>
						<text class="task-date">{{ task.date }}</text>
					</view>
					<view class="task-type-badge" :class="getTypeClass(task.type)">
						{{ task.type }}
					</view>
				</view>

				<view class="task-content">
					<view class="info-row">
						<uni-icons type="person" size="16" color="#999"></uni-icons>
						<text class="info-text">车主信息</text>
					</view>

					<view class="info-row">
						<uni-icons type="car" size="16" color="#999"></uni-icons>
						<text class="info-text">车辆信息</text>
					</view>

					<view class="info-row">
						<uni-icons type="location" size="16" color="#999"></uni-icons>
						<text class="info-text">取车位置</text>
					</view>
				</view>

				<view class="task-footer">
					<button class="detail-btn" @click.stop="viewDetail(task.id)">
						<uni-icons type="eye" size="14" color="#fff"></uni-icons>
						<text>查看详情</text>
					</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 搜索文本
				searchText: '',
				// 状态筛选选项
				statusOptions: ['全部', '进行中', '已完成', '已取消'],
				selectedStatus: '全部',
				// 维修方式筛选选项
				repairTypeOptions: ['全部', '到店维修', '上门取车'],
				selectedRepairType: '全部',
				// 任务列表数据
				tasks: [{
						id: '3535252',
						status: '进行中',
						type: '到店维修',
						date: '2023-03-18 11:00'
					},
					{
						id: '3535252',
						status: '已完成',
						type: '上门取车',
						date: '2023-03-18 11:00'
					},
					{
						id: '3535252',
						status: '进行中',
						type: '上门取车',
						date: '2023-03-18 11:00'
					}
				]
			};
		},
		methods: {
			// 返回上一页
			goBack() {
				uni.navigateBack();
			},
			// 状态筛选变化
			onStatusChange(e) {
				this.selectedStatus = this.statusOptions[e.detail.value];
				// 这里可以添加筛选逻辑
			},
			// 维修方式筛选变化
			onRepairTypeChange(e) {
				this.selectedRepairType = this.repairTypeOptions[e.detail.value];
				// 这里可以添加筛选逻辑
			},
			// 查看详情
			viewDetail(id) {
				uni.navigateTo({
					url: `/pages/repair-tasks/maintenancetaskdetail/maintenancetaskdetail?orderNo=${id}`
				});
			},
			// 获取状态样式类
			getStatusClass(status) {
				const statusMap = {
					'进行中': 'status-processing',
					'已完成': 'status-completed',
					'已取消': 'status-cancelled',
					'待处理': 'status-pending'
				};
				return statusMap[status] || 'status-pending';
			},
			// 获取维修方式样式类
			getTypeClass(type) {
				const typeMap = {
					'到店维修': 'type-shop',
					'上门取车': 'type-pickup'
				};
				return typeMap[type] || 'type-shop';
			}
		}
	};
</script>

<style>
	.container {
		background: linear-gradient(135deg, #2a8cff 0%, #764ba2 100%);
		min-height: 100vh;
	}

	/* 顶部安全区域 */
	.status-bar {
		height: var(--status-bar-height);
		background: linear-gradient(135deg, #2a8cff 0%, #764ba2 100%);
	}

	/* 搜索栏 */
	.search-container {
		padding: 20rpx;
		background: linear-gradient(135deg, #2a8cff 0%, #764ba2 100%);
	}

	.search-box {
		display: flex;
		align-items: center;
		background-color: rgba(255, 255, 255, 0.95);
		border-radius: 50rpx;
		padding: 20rpx 30rpx;
		backdrop-filter: blur(10rpx);
		box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.1);
	}

	.search-icon {
		margin-right: 15rpx;
	}

	.search-input {
		flex: 1;
		font-size: 28rpx;
		color: #333;
		height: 40rpx;
		line-height: 40rpx;
	}

	.search-input::placeholder {
		color: #999;
	}

	/* 筛选栏 */
	.filter-bar {
		display: flex;
		justify-content: space-between;
		align-items: center;
		background: linear-gradient(135deg, #2a8cff 0%, #764ba2 100%);
		padding: 0 20rpx 20rpx;
	}

	.stats-info {
		display: flex;
		align-items: center;
	}

	.total-count {
		font-size: 26rpx;
		color: rgba(255, 255, 255, 0.9);
		font-weight: 500;
	}

	.filter-options {
		display: flex;
		align-items: center;
		gap: 15rpx;
	}

	.filter-item {
		display: flex;
		align-items: center;
	}

	.filter-value {
		font-size: 24rpx;
		color: #fff;
		display: flex;
		align-items: center;
		background-color: rgba(255, 255, 255, 0.2);
		padding: 8rpx 12rpx;
		border-radius: 16rpx;
		backdrop-filter: blur(10rpx);
	}

	.filter-value text {
		margin-right: 6rpx;
	}

	.date-filter {
		display: flex;
		align-items: center;
		background-color: rgba(255, 255, 255, 0.2);
		padding: 8rpx 12rpx;
		border-radius: 16rpx;
		backdrop-filter: blur(10rpx);
	}

	.date-text {
		font-size: 24rpx;
		color: #fff;
		margin-left: 6rpx;
	}

	/* 任务列表 */
	.task-list {
		padding: 20rpx;
	}

	/* 任务项 */
	.task-item {
		background-color: #fff;
		border-radius: 20rpx;
		padding: 30rpx;
		margin-bottom: 20rpx;
		box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.1);
		position: relative;
		overflow: hidden;
		transition: all 0.3s ease;
	}

	.task-item:active {
		transform: translateY(2rpx);
		box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.15);
	}

	/* 状态标签 */
	.task-status-badge {
		position: absolute;
		top: 20rpx;
		right: 20rpx;
		padding: 6rpx 12rpx;
		border-radius: 12rpx;
		font-size: 22rpx;
		font-weight: 500;
		color: #fff;
	}

	.status-processing {
		background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
	}

	.status-completed {
		background: linear-gradient(135deg, #d299c2 0%, #fef9d7 100%);
		color: #333;
	}

	.status-cancelled {
		background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
		color: #333;
	}

	.status-pending {
		background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
		color: #333;
	}

	.task-header {
		display: flex;
		justify-content: space-between;
		align-items: flex-start;
		margin-bottom: 25rpx;
		padding-bottom: 20rpx;
		border-bottom: 1px solid #f0f0f0;
	}

	.task-number-section {
		flex: 1;
	}

	.task-id {
		font-size: 30rpx;
		font-weight: 600;
		color: #333;
		display: block;
		margin-bottom: 8rpx;
	}

	.task-date {
		font-size: 24rpx;
		color: #999;
	}

	.task-type-badge {
		padding: 6rpx 12rpx;
		border-radius: 12rpx;
		font-size: 22rpx;
		font-weight: 500;
	}

	.type-shop {
		background: linear-gradient(135deg, #2a8cff 0%, #764ba2 100%);
		color: #fff;
	}

	.type-pickup {
		background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
		color: #fff;
	}

	.task-content {
		margin-bottom: 25rpx;
	}

	.info-row {
		display: flex;
		align-items: center;
		margin-bottom: 15rpx;
	}

	.info-row:last-child {
		margin-bottom: 0;
	}

	.info-text {
		font-size: 26rpx;
		color: #666;
		margin-left: 12rpx;
		flex: 1;
	}

	.task-footer {
		display: flex;
		justify-content: flex-end;
		padding-top: 20rpx;
		border-top: 1px solid #f0f0f0;
	}

	.detail-btn {
		background: linear-gradient(135deg, #2a8cff 0%, #764ba2 100%);
		color: #fff;
		font-size: 26rpx;
		padding: 12rpx 24rpx;
		border-radius: 25rpx;
		display: flex;
		align-items: center;
		box-shadow: 0 4rpx 16rpx rgba(102, 126, 234, 0.3);
		transition: all 0.3s ease;
	}

	.detail-btn text {
		margin-left: 8rpx;
	}

	.detail-btn:active {
		transform: translateY(1rpx);
		box-shadow: 0 2rpx 8rpx rgba(102, 126, 234, 0.4);
	}
</style>